﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Automted_Bank_teller
{
    public partial class payBills : Form
    {
        public payBills()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                payBillsLogic bill = new payBillsLogic();
                bill.Database_ConnectString();
                bill.payBill(float.Parse(textBox2.Text), float.Parse(textBox3.Text), float.Parse(textBox4.Text));
                textBox5.Text = bill.return_allmoeny().ToString();
                bill.Open_Database();
                bill.update(float.Parse(textBox5.Text));
                if (bill.ExecuteQuery() == 1)
                {
                    MessageBox.Show(" successfully your balance :" + bill.return_allmoeny());
                }
                else if (bill.ExecuteQuery() == 2)
                {
                    MessageBox.Show("error Occured");
                }
                bill.Close_Database();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void payBills_Load(object sender, EventArgs e)
        {
            try
            {
                payBillsLogic payBills = new payBillsLogic();
                payBills.Database_ConnectString();
                payBills.showBalance();
                payBills.Open_Database();
                if (payBills.get_Balance() == false)
                {
                    MessageBox.Show("error Occured.Changes discarded");
                }
                payBills.bills();
                textBox1.Text = payBills.return_balance().ToString();
                textBox2.Text = payBills.return_sales().ToString();
                textBox3.Text = payBills.return_purchases().ToString();
                textBox4.Text = payBills.return_dues().ToString();
                payBills.Close_Database();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }

       
    }
}
